package com.wanban.download.model

import androidx.annotation.IntDef

@IntDef(Status.IDLE, Status.PENDING, Status.PREPARE, Status.START, Status.DOWNLOADING, Status.STOP, Status.ERROR, Status.SUCCESS, Status.DELETE)
@Retention(AnnotationRetention.SOURCE)
annotation class Status {
    companion object {
        /** 默认状态 */
        const val IDLE = 0
        /** 当下载任务正式运行加入下载队列的状态 */
        const val PENDING = 1
        /** 允许启动下载 */
        const val PREPARE = 2
        /** 真正开始下载 */
        const val START = 3
        const val DOWNLOADING = 4
        const val STOP = 5
        const val ERROR = 6
        const val SUCCESS = 7
        const val DELETE = 8


        fun getStatusName(@Status status: Int): String{
            return when (status){
                PENDING         -> "排队"
                PREPARE         -> "启动任务"
                START           -> "准备下载"
                DOWNLOADING     -> "下载中"
                STOP            -> "暂停"
                ERROR           -> "出错"
                SUCCESS         -> "完成"
                DELETE          -> "删除"
                else -> "闲置"
            }
        }
    }

}